package com.ibeetl.codestory.core.action;

import com.ibeetl.codestory.core.ast.Ast;
import com.ibeetl.codestory.core.ctx.Context;
import com.ibeetl.codestory.core.match.Matcher;
import com.ibeetl.codestory.core.ast.AstType;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public abstract class MethodInvokeAction implements Action {
	public static final Set<AstType> AST_TYPE = new HashSet<>(Arrays.asList(AstType.MethodInvoke));
	public void on(Ast ast, Context ctx){
		Matcher matcher = acceptMatcher();
		if(!matcher.match(ast)){
			return ;
		}
		methodInvoke(ast,ctx);
	}
	public abstract void methodInvoke(Ast ast, Context ctx);

	public  abstract  Matcher acceptMatcher();

	public Set<AstType> acceptType(){
		return AST_TYPE;
	}

}
